import cv2

img=cv2.imread("p1.jpg")
face=cv2.CascadeClassifier(cv2.data.haarcascades+'haarcascade_frontalface_default.xml')
faces=face.detectMultiScale(img,scaleFactor=1.3,minNeighbors=3)

for (x,y,w,h) in faces:
    img=cv2.rectangle(img,(x,y),(x+w,y+h),(125,89,247),7)
# bgr模式，b蓝色。g绿色，r红色
cv2.imshow("show",img)
cv2.waitKey(0)
cv2.destroyAllWindows()















# import cv2

# img = cv2.imread('p1.jpg',1)
# face = cv2.CascadeClassifier(cv2.data.haarcascades+'haarcascade_frontalface_default.xml')
# faces = face.detectMultiScale(img,scaleFactor=1.3,minNeighbors=5)

# for (x,y,w,h) in faces:
#     img = cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)

# cv2.imshow('img',img)
# cv2.waitKey(0)
# cv2.destroyAllWindows()
